<?php
/**
 * Created by PhpStorm.
 * User: xianshaofeng
 * Date: 2018/7/24
 * Time: 15:10
 */

namespace app\admin\controller;

use app\admin\model\Manage as ManageModel;

class Manage extends Permissions
{
    public function lists(){
        $model=new ManageModel();

        $post = $this->request->param();
        if (isset($post['keywords']) and !empty($post['keywords'])) {
            $where['nickname'] = ['like', '%' . $post['keywords'] . '%'];
        }
        if (isset($post['admin_cate_id']) and $post['admin_cate_id'] > 0) {
            $where['admin_cate_id'] = $post['admin_cate_id'];
        }

        if(isset($post['create_time']) and !empty($post['create_time'])) {
            $min_time = strtotime($post['create_time']);
            $max_time = $min_time + 24 * 60 * 60;
            $where['create_time'] = [['>=',$min_time],['<=',$max_time]];
        }
        $manage = empty($where) ? $model->order('create_time desc')->paginate(20) : $model->where($where)->order('create_time desc')->paginate(20,false,['query'=>$this->request->param()]);

        $this->assign('manage',$manage);

        return $this->fetch();
    }
}